<template>
  <!--          create Loan dialogue     *************************************** -->
  <el-dialog :title="createLoanRemark.title" :visible="isVisible" :before-close="hide">
    <el-form ref="createLoanValue" :model="createLoanValue" label-width="120px">
      <el-form-item :label="createLoanRemark.prover">
        <el-select
          v-model="createLoanValue.approverId"
          placeholder="please select your approver"
        >
          <el-option
            v-for="item in createLoanRemark.proverOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="createLoanRemark.type">
        <el-select
          v-model="createLoanValue.type"
          placeholder="please select your loan type"
        >
          <el-option
            v-for="item in createLoanRemark.typeOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="createLoanRemark.totalMoney">
        <el-input v-model="createLoanValue.totalMoney" />
      </el-form-item>
      <el-form-item :label="createLoanRemark.interestRate">
        <el-input v-model="createLoanValue.interestRate" />
      </el-form-item>
      <el-form-item :label="createLoanRemark.createdTime">
        <el-col :span="11">
          <el-date-picker
            v-model="createLoanValue.createdTimeNNN"
            type="date"
            placeholder="Pick a date"
            style="width: 100%"
          />
        </el-col>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="createLoan">创建</el-button>
        <el-button @click="hide">取消</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>
<script>
export default {
  props: {
    isVisible: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  data() {
    return {
      createLoanValue: {
        approverId: "",
        type: "",
        totalMoney: "",
        interestRate: "0.4",
        createdTime: "",
        url: "/basic/loan/add",
      },
      createLoanRemark: {
        prover: "贷款人",
        proverOptions: [
          {
            label: "银行",
            value: "1234",
          },
          {
            label: "其他人",
            value: "1234567",
          },
        ],
        type: "贷款类型",
        typeOptions: [
          {
            label: "信用贷",
            value: "CreditLoan",
          },
          {
            label: "抵押物贷款",
            value: "MortgageLoan",
          },
        ],
        totalMoney: "总额",
        interestRate: "利率",
        createdTime: "贷款时间",
      },
    };
  },
  created() {
  },
  methods: {
    createLoan() {
      this.$store.dispatch("request/post", this.createLoanValue).then(() => {
        this.$message.success("请求贷款成功!!");
        this.$emit("updateData");
      });
    },
    hide(){
        this.$emit("hide");
    }
  },
};
</script>